package com.siao.example.libaray.component.view
{
	import com.siao.example.common.ui.Layer;
	import com.siao.example.libaray.component.method.ComponentMethod;
	import com.siao.example.libaray.component.ui.ComponentMenuBar;
	import com.siao.mvc.View;
	
	import flash.events.MouseEvent;
	
	/**
	 * 组件视图
	 * @author SiaoLeon
	 */
	public class ComponentView extends View
	{
		// -------------------------------------------------------------------------------------------------------- 静态常量
		
		// -------------------------------------------------------------------------------------------------------- 静态变量
		
		// -------------------------------------------------------------------------------------------------------- 静态方法
		
		// -------------------------------------------------------------------------------------------------------- 静态函数
		
		// -------------------------------------------------------------------------------------------------------- 属性
		
		// -------------------------------------------------------------------------------------------------------- 变量
		
		/**
		 * 显示菜单
		 */
		private var menu:ComponentMenuBar;
		
		// -------------------------------------------------------------------------------------------------------- 构造
		
		/**
		 * 构造函数
		 */
		public function ComponentView()
		{
			super();
		}
		
		// -------------------------------------------------------------------------------------------------------- 方法
		
		override public function onAdd():void
		{
			this.menu = new ComponentMenuBar();
			this.menu.addEventListener(MouseEvent.CLICK, onClick);
			Layer.instance.content.addChild(this.menu);
		}
		
		override public function onRemove():void
		{
			Layer.instance.content.removeChild(this.menu);
			this.menu = null;
		}
		
		// -------------------------------------------------------------------------------------------------------- 函数
		
		private function onClick(event:MouseEvent):void
		{
			switch (event.target)
			{
				case this.menu.btnScrollbar:
					this.notify(ComponentMethod.ENTER_COMPONENT_SCROLLBAR);
					break;
				
				case this.menu.btnList:
					this.notify(ComponentMethod.ENTER_COMPONENT_LIST);
					break;
				
				case this.menu.btnStack:
					this.notify(ComponentMethod.ENTER_COMPONENT_STACK);
					break;
				
				case this.menu.btnScrollList:
					this.notify(ComponentMethod.ENTER_COMPONENT_SCROLLLIST);
					break;
				
				case this.menu.btnScrollPanel:
					this.notify(ComponentMethod.ENTER_COMPONENT_SCROLLPANEL);
					break;
				
				case this.menu.btnComboBox:
					this.notify(ComponentMethod.ENTER_COMPONENT_COMBOBOX);
					break;
			}
		}
	
	}
}
